package com.example.agriculture.service.impl;

import com.example.agriculture.dao.ProducerDao;
import com.example.agriculture.entity.Producer;
import com.example.agriculture.service.ProducerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Producer)表服务实现类
 *
 * @author makejava
 * @since 2022-09-12 15:24:18
 */
@Service("producerService")
public class ProducerServiceImpl implements ProducerService {
    @Resource
    private ProducerDao producerDao;


    @Override
    public Producer producer(String producer_number, String producer_password) {
        return producerDao.producer_login(producer_number,producer_password);
    }

    @Override
    public int producer(Producer producer) {
        return producerDao.insert(producer);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param producerId 主键
     * @return 实例对象
     */
    @Override
    public Producer queryById(Integer producerId) {
        return this.producerDao.queryById(producerId);
    }

    @Override
    public int produceruppwd(String producerPassword, Integer producerId) {
        return producerDao.produceruppwd( producerPassword, producerId);
    }

    @Override
    public List<Producer> queryAllLimit(int offset, int limit, String keyword) {
        return producerDao.queryAllLimit(offset,limit,keyword);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Producer> queryAllByLimit(int offset, int limit) {
        return this.producerDao.queryAllByLimit(offset, limit);
    }

    @Override
    public int upProducerMoney(Integer producerId, Float producerMoney) {
        return producerDao.upProducerMoney(producerId,producerMoney);
    }

    /**
     * 新增数据
     *
     * @param producer 实例对象
     * @return 实例对象
     */
    @Override
    public Producer insert(Producer producer) {
        this.producerDao.insert(producer);
        return producer;
    }

    /**
     * 修改数据
     *
     * @param producer 实例对象
     * @return 实例对象
     */
    @Override
    public Producer update(Producer producer) {
        this.producerDao.update(producer);
        return this.queryById(producer.getProducerId());
    }

    /**
     * 通过主键删除数据
     *
     * @param producerId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer producerId) {
        return this.producerDao.deleteById(producerId) > 0;
    }

    @Override
    public int count() {
        return producerDao.count();
    }

    @Override
    public int countLimit(String keyword) {
        return producerDao.countLimit(keyword);
    }

    @Override
    public List<Producer> SelectAllProducer() {
        return producerDao.SelectAllProducer();
    }

    @Override
    public Producer updateMoney(float producerMoney) {
        return producerDao.updateMoney(producerMoney);
    }

    @Override
    public int queryAllCount(String producerNumber) {
        return producerDao.queryAllCount(producerNumber);
    }

    @Override
    public int login(String number) {
        return producerDao.login(number);
    }


}